Heteroatom-doped carbon materials have attracted immense interest as advanced supercapacitor electrode materials due to their unique properties. A carbon cloth-supported, nitrogen-doped carbon “spider web” network full of macropores and mesopores is developed via the pyrolysis of polyaniline nanofibers in ammonia atmosphere. The presence of mesopores and macropores can provide ion-buffering reservoirs to shorten the ion diffusion distance to the interior part of the carbon network. Carbonization in ammonia introduced N heteroatoms through gas phase chemical reactions between ammonia and the oxygen functionalities on the carbon surface. The enhanced ion-accessible surface area and improved charge transfer rate can be achieved. The N-doped carbon “spider web” exhibited a high specific capacitance of 266 F/g at a scan rate of 2 mV/s. Even when the scan rate was increased to 500 mV/s, 61% of its capacitance could still be retained, evidencing its excellent rate performance. The demonstrated strategy is anticipated to be generally effective for preparing heteroatom-doped carbon electrodes with other polymers.